<template>
    <div style="height: 100%;width: 100%">
      <returnActionList></returnActionList>
      <!--<div style="width: 100%" class="fd itemcenter f-l" v-for="(item,index) of organizationList ">-->
        <div style="width: 100%" class="fd itemcenter f-l" v-for="(item,index) of this.$store.getters.getOrganizationList ">
        <div class="bg-w m-top30" style="width: 70%">
          <div class="c-g fs20 fw">{{item.organizationName}}</div>
          <div class="fr between c-dimgrey">
            <div class="fs18">编码：{{index}}</div>
            <div>
              <el-button type="warning" @click="cutOrganization(index,item.organizationName)" v-if='$store.getters.getUserPresentOrganization!==index'>切换</el-button>
              <span class="fs15" v-else-if="$store.getters.getUserPresentOrganization===index">当前机构</span>
            </div>
          </div>
        </div>
      </div>
    </div>
</template>

<script>
    export default {
        name: "SetOrganization",
      data(){
          return{
            organizationList:[
              {organizationName:'样品机构',num:'123458'},
              {organizationName:'样品机构',num:'123457'},
              {organizationName:'样品机构',num:'123456'},
              ],
            presentOrganization:''
          }
      },
      methods:{
        cutOrganization:function (organizationNum,organizationName) {
          console.log(organizationName)
          this.$confirm('是否切换到'+organizationName, '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            this.$store.commit('setUserPresentOrganization', organizationNum);
            this.$message({
              type: 'success',
              message: '切换成功!'
            });
          }).catch(() => {
            this.$message({
              type: 'info',
              message: '切换失败'
            });
          });
        }
      },
      created(){
          Object.keys(this.$store.getters.getOrganizationList).forEach((key)=>{
            console.log(key,this.$store.getters.getOrganizationList[key].organizationName)
          })
        this.presentOrganization =this.$store.getters.getUserPresentOrganization
          // console.log(this.$store.getters.getOrganizationList)
        console.log(this.$store.getters.getUserPresentOrganization)
      }
    }
</script>

<style scoped>

</style>
